package com.gly091020.config;

import com.gly091020.MathDragon;
import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.Config;
import me.shedaniel.autoconfig.annotation.ConfigEntry;

@Config(name = MathDragon.ModID)
@Config.Gui.Background("minecraft:textures/block/end_stone.png")
public class MathDragonConfig implements ConfigData {
    public boolean useMathDragon = true;
    @ConfigEntry.Gui.CollapsibleObject
    @ConfigEntry.Gui.Tooltip
    public SwitchFunction switchFunction = new SwitchFunction();
    @ConfigEntry.BoundedDiscrete(min = 1, max = 50)
    public boolean doDragonCharging = false;
    @ConfigEntry.BoundedDiscrete(min = 1, max = 50)
    public int answerQuestionTime = 10;
    public boolean renderGly = true;

    @ConfigEntry.Gui.CollapsibleObject(startExpanded = true)
    public MathematicalSetting mathematicalSetting = new MathematicalSetting();

    public static class SwitchFunction{
        public boolean endCrystal = true;
        public boolean dragonBall = true;
        public boolean dragon = true;
    }

    public enum DigitCount{
        Ten,Hundred,Thousand;
        public int getMax(){
            switch (this){
                case Ten -> {return 9;}
                case Hundred -> {return 99;}
                case Thousand -> {return 999;}
            }
            return 9;
        }

        public int getMin(){
            switch (this){
                case Ten -> {return 1;}
                case Hundred -> {return 10;}
                case Thousand -> {return 100;}
            }
            return 9;
        }

        @Override
        public String toString() {
            switch (this){
                case Ten -> {return "个位";}
                case Hundred -> {return "十位";}
                case Thousand -> {return "百位";}
            }
            return "";
        }
    }

    public static class MathematicalSetting{

        @ConfigEntry.Gui.CollapsibleObject
        public Addition addition = new Addition();
        @ConfigEntry.Gui.CollapsibleObject
        public Subtraction subtraction = new Subtraction();
        @ConfigEntry.Gui.CollapsibleObject
        public Multiplication multiplication = new Multiplication();
        @ConfigEntry.Gui.CollapsibleObject
        public Division division = new Division();

        public static class Addition{
            public boolean enable = true;
            @ConfigEntry.Gui.EnumHandler
            public DigitCount count = DigitCount.Hundred;
            public boolean overTheLimit = false;
        }
        public static class Subtraction{
            public boolean enable = true;
            public DigitCount count = DigitCount.Hundred;
            public boolean overTheLimit = false;
        }
        public static class Multiplication{
            public boolean enable = true;
            public DigitCount count = DigitCount.Hundred;
            public DigitCount num1 = DigitCount.Ten;
            public DigitCount num2 = DigitCount.Ten;
            public boolean overTheLimit = false;
        }
        public static class Division{
            public boolean enable = true;
            public DigitCount num1 = DigitCount.Hundred;
            public DigitCount num2 = DigitCount.Ten;
            public boolean overTheLimit = false;
        }
    }
}
